<style lang="scss" scoped>
    @import '../../css/training.scss';

    @import '../../css/exam2.scss';


</style>

<template>
    <section>

        <section class="breadcrumb-box clearfix">
            <el-breadcrumb separator=" > " class="fl">
                <el-breadcrumb-item >培训</el-breadcrumb-item>
                <el-breadcrumb-item :to="{path: '/training/training-manage'}">培训管理</el-breadcrumb-item>
                <el-breadcrumb-item v-if="$route.meta">{{$route.meta.title}}</el-breadcrumb-item>
            </el-breadcrumb>
        </section>

        <section class="exam-box">

            <section class="train-name pt30">《多麦企业文化培训》考试</section>

            <section class="traniing-info-tab exam-info-tab p-relative">
                <span v-for="item,$index in tabList" :class="{'active': tabIndex ==$index}" @click="tabActive($index)">{{item}}</span>
                <div class="p-absolute exam-info-tabr">
                    <span class="mr20" @click="goto('/training/exam-preview')">预览</span>
                    <span class="ml from-bank" @click="testBankFlag = true">+  从题库选题</span>
                </div>
            </section>

            <!-- 没有试卷 -->
            <section v-if="step==0" class="exam-space">
                <span class="exam-space-item space-iconf" @click="step=1">
                    <img src="../../images/Training-ic-paper.png" alt="">
                    <span class="space-txt fs-14 mt">新建空白试卷</span>
                </span>
                <div class="exam-space-item" @click="testPaperFlag = true">
                    <img src="../../images/Training-ic-Test-paper.png" alt="">
                    <span class="space-txt fs-14 mt">试卷库中选择</span>
                </div>
            </section>

            <!-- 编辑试卷 -->
            <section v-else-if="step==1">

                    <el-form ref="exam-form" :model="form" :rules="rules" class="mt30">

                        <el-form-item label="考试名称" prop="title">
                            <el-input v-model="title"></el-input>
                        </el-form-item>
                        <el-form-item label="考试描述" prop="desc">
                            <el-input v-model="desc"></el-input>
                        </el-form-item>
                        <el-form-item label="合格分数" prop="passScore">
                            <el-input v-model="passScore"></el-input>
                        </el-form-item>
                        <el-form-item label="考试时长" prop="allowCostTime">
                            <el-input v-model="allowCostTime"></el-input>
                        </el-form-item>

                        <el-form-item label="知识体系">
                            <el-select v-model="form.infoCateID" placeholder="请选择活动区域">
                                <el-option :label="one.CateName" :value="one.InfoCateID" v-for="one in InfoCateList" :key="one"></el-option>

                            </el-select>
                        </el-form-item>

                        <div class="form-sepa mt20">

                            <!--初始化选择题-->
                            <div class="exam-addbox mt20">
                                <span class="exama-one exama-i0" @click="addOne(2)">单选题</span>
                                <span class="exama-one exama-i1" @click="addOne(1)">多选题</span>
                                <span class="exama-one exama-i2" @click="addOne(3)">问答题</span>
                            </div>

                            <!-- 开始题目循环 -->
                            <template v-for="outer,index in form.Questions">   <!-- QuestionType:1, 多选题  2，单选题 3，问答 -->
                                <!-- 单选题+多选题 -->
                                <template v-if="!outer.editFlag">  <!-- 显示状态 -->
                                    <div class="exam-one clearfix mt20" v-if="outer.QuestionType!=3">
                                        <div class="examo-lef">
                                            <div class="">Q{{index+1}}</div>
                                            <div class="examo-do examo-edit mt" @click="editOne(index)"></div>
                                            <div class="examo-do examo-del" @click="delOne"></div>
                                        </div>
                                        <div class="examo-rig">
                                            <!-- 标题 -->
                                            <div class="examo-tit examo-line  clearfix">
                                                <div class="examo-f01">
                                                    <span v-if="outer.QuestionType==1">【多选题】</span>
                                                    <span v-else>【单选题】</span>

                                                    <span class="">{{outer.QuestionTitle}}</span>
                                                </div>
                                                <div class="examo-f02">
                                                    <span>{{outer.RightScore}}</span>
                                                    <span>分</span>
                                                </div>
                                            </div>
                                            <!-- 选项 -->
                                            <div class="examo-one examo-line mt20 clearfix" v-for="one,iIndex in outer.Answers">
                                                <div class="examo-f00">
                                                    <el-radio v-model="outer.RightAnswerIndex" :label="iIndex" v-if="outer.QuestionType==2" disabled="true">{{answerArr[iIndex]}}</el-radio>
                                                    <label v-else disabeld>
                                                        <span class="exam-checkbox" :class="judgeCheckOn(iIndex, outer.RightAnswerIndex)?'checked':''"></span>
                                                    </label>
                                                    <span>{{one.AnswerValue}}</span>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 问答题 -->
                                    <div class="exam-one clearfix mt20" v-else>
                                        <div class="examo-lef">
                                            <div class="">Q{{index+1}}</div>
                                            <div class="examo-do examo-edit mt" @click="editOne(index)"></div>
                                            <div class="examo-do examo-del" @click="delOne(index)"></div>
                                        </div>
                                        <div class="examo-rig">

                                            <div class="examo-one examo-line clearfix">
                                                <div class="examo-f00">
                                                    <!--<el-input class="examo-inp00" placeholder="标题"></el-input>-->
                                                    {{outer.QuestionTitle}}
                                                </div>
                                                <div class="examo-f01">
                                                    <span>【问答题】</span>
                                                </div>
                                            </div>
                                            <div class="mt20">
                                                {{outer.Answers[0].AnswerValue}}
                                                <!--<el-input type="textarea" :rows="5" placeholder="请输入问答答案...">
                                                </el-input>-->
                                            </div>
                                        </div>
                                    </div>

                                </template>

                                <tempalte v-else>   <!-- 编辑状态 -->
                                    <div class="exam-one clearfix mt20" v-if="outer.QuestionType!=3">
                                        <div class="examo-lef">
                                            <div class="">Q{{index+1}}</div>
                                            <!--<div class="examo-do examo-edit mt"></div>
                                            <div class="examo-do examo-del"></div>-->
                                        </div>
                                        <div class="examo-rig">
                                            <!-- 标题 -->
                                            <div class="examo-tit clearfix">
                                                <div class="examo-f00">
                                                    <el-input class="examo-inp00" placeholder="标题" v-model="outer.QuestionTitle"></el-input>
                                                </div>
                                                <div class="examo-f01">
                                                    <span v-if="outer.QuestionType==1">【多选题】</span>
                                                    <span v-else>【单选题】</span>
                                                </div>
                                                <div class="examo-f02">
                                                    <span>分值</span>
                                                    <el-input class="examo-inp01" v-model="outer.RightScore"></el-input>
                                                    <span>分</span>
                                                </div>
                                            </div>
                                            <!-- 选项 -->
                                            <div class="examo-one mt20 clearfix" v-for="one,iIndex in outer.Answers">
                                                <div class="examo-f00">

                                                    <!--<span v-if="outer.QuestionType==2"><el-radio disabled="true"></el-radio></span>
                                                    <span v-else><el-checkbox disabled></el-checkbox></span>-->
                                                    <el-radio v-model="outer.RightAnswerIndex" :label="iIndex" v-if="outer.QuestionType==2">{{answerArr[iIndex]}}</el-radio>
                                                    <label @click="checkAnswerOne(iIndex, outer.RightAnswerIndex, 3)" v-else>
                                                        <span class="exam-checkbox" :class="judgeCheckOn(iIndex, outer.RightAnswerIndex)?'checked':''"></span>
                                                        <span>{{answerArr[iIndex]}}</span>
                                                    </label>

                                                    <!--<span class="mr">{{answerArr[iIndex]}}</span>-->
                                                    <el-input class="examo-inp02 ml" placeholder="标题" v-model="one.AnswerValue"></el-input>

                                                </div>
                                                <div class="examo-f01">

                                                    <el-radio v-model="outer.RightAnswerIndex" :label="iIndex" v-if="outer.QuestionType==2">设为答案</el-radio>
                                                    <label @click="checkAnswerOne(iIndex, outer.RightAnswerIndex, 3)" v-else>
                                                        <span class="exam-checkbox" :class="judgeCheckOn(iIndex, outer.RightAnswerIndex)?'checked':''"></span>
                                                        <span>设为答案</span>
                                                    </label>

                                                    <!--<el-radio label="1">设为答案</el-radio>-->
                                                </div>
                                                <div class="examo-f02">
                                                    <span class="examo-do examo-tot"></span>
                                                    <span class="examo-do examo-tob"></span>
                                                    <span class="examo-do examo-del" @click="delAnswerOne(index,iIndex)"></span>
                                                </div>
                                            </div>
                                            <!-- 添加按钮 -->
                                            <div class="examo-add mt20" @click="addAnswerOne(index)">+添加选项</div>
                                            <div class="examo-save mt20" @click="saveAnswerOne(index, outer.QuestionType)" v-if="outer.editFlag">保存</div>
                                        </div>
                                    </div>
                                    <!-- 问答题 -->
                                    <div class="exam-one clearfix mt20" v-else>
                                        <div class="examo-lef">
                                            <div class="">Q{{index+1}}</div>
                                            <div></div>
                                            <div></div>
                                        </div>
                                        <div class="examo-rig">

                                            <div class="examo-one clearfix">
                                                <div class="examo-f00">
                                                    <el-input class="examo-inp00" placeholder="标题" v-model="outer.QuestionTitle"></el-input>
                                                </div>
                                                <div class="examo-f01">
                                                    <span>【问答题】</span>
                                                </div>
                                            </div>
                                            <div class="mt20">
                                                <el-input type="textarea" :rows="5" placeholder="请输入问答答案..." v-model="outer.Answers[0].AnswerValue">
                                                </el-input>
                                            </div>
                                            <div class="examo-save mt20" @click="saveAnswerOne(index, outer.QuestionType)" v-if="outer.editFlag">保存</div>
                                        </div>
                                    </div>
                                </tempalte>

                            </template>


                            <!--添加题目-->
                            <div class="exam-addbox mt20">
                                <span class="exama-add mr"></span>
                                <template v-if="addBtnFlag">
                                    <span class="exama-one exama-tip" @mouseover="addOver">添加题目</span>
                                </template>
                                <template v-else>
                                    <div class="exama-dos" @mouseout="outAddBtn" @mousemove="moveAddBtn">
                                        <span class="exama-one exama-i0" @click="addOne(2,true)">单选题</span>
                                        <span class="exama-one exama-i1" @click="addOne(1,true)">多选题</span>
                                        <span class="exama-one exama-i2" @click="addOne(3,true)">问答题</span>
                                    </div>
                                </template>
                            </div>

                        </div>

                        <div class="exama-minor mt20">
                            <el-checkbox v-model="isJoinExamLib" value="0">将试卷保存到试卷库</el-checkbox>
                            <el-checkbox v-model="isJoinQuestionLib" value="0">将试题保存到题库</el-checkbox>
                        </div>

                        <!--<el-form-item>-->
                        <el-button type="primary" @click="submitForm('exam-form')">提交</el-button>
                        <!--</el-form-item>-->

                    </el-form>

                </section>

            <!-- 方法试卷 -->
            <section v-else-if="step==2">

                </section>

            <!-- 考试结果 -->
            <section v-else-if="step==3">

                </section>

        </section>

        <!--试卷详情查看-->
        <el-dialog
                title="试卷详情"
                :visible.sync="showPaperDetail"
                width="50%"
                center>
            <section class="detail-stu-info fs-14">
                <span class="mt20">姓名：smile</span>
                <span class="mt20">工号：219</span>
                <span class="mt20">公司：219</span>
                <span class="mt20">手机：15637882778</span>
            </section>
            <section class="detail-stu-score fs-14 mt20">
                <div class="p-relative detail-stu-title">
                    <span class="p-absolute exam-space-linet">考试结果</span>
                    <div class="exam-space-line"></div>
                </div>
                <p class="mt20"><span>得分：20分</span><span class="stu-test-status ml20">通过</span></p>
                <p class="mt20">排名：第1名</p>
            </section>
            <section class="mt30">
                <div class="p-relative detail-stu-title">
                    <span class="p-absolute exam-space-linet">问卷</span>
                    <div class="exam-space-line"></div>
                </div>
                <ul>
                    <li class="p-relative mt exam-question ">
                        <div class="question-content mt20">
                            <p class="question-topic">
                                <span>1</span>
                                <span>【单选题】</span>
                                <span>迟到几次不扣工资</span>
                            </p>
                            <ul class="question-options">
                                <el-radio-group v-model="questionRadio">
                                    <li class="mt20 fs-14">
                                        <el-radio label="1" disabled >A<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="2" disabled >B<span class="ml20"></span> 1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="3" disabled >C<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="4" >D<span class="ml20"></span>1次</el-radio>
                                    </li>
                                </el-radio-group>
                            </ul>
                            <div class="question-down clearfix mt20">
                                <span class="fs-14 question-down-left fl fs-14">学员回答∶B</span>
                                <span class="fr">
                                    <img src="../../images/correct-icon.png" alt="">
                                    <span class="fs-14 question-down-right">（得10分）</span>
                                </span>
                            </div>
                        </div>
                        <div class="p-absolute answers-score">（10分）</div>
                    </li>
                    <li class="p-relative mt exam-question ">
                        <div class="question-content mt20">
                            <p class="question-topic">
                                <span>1</span>
                                <span>【单选题】</span>
                                <span>迟到几次不扣工资</span>
                            </p>
                            <ul class="question-options">
                                <el-radio-group v-model="questionRadio">
                                    <li class="mt20 fs-14">
                                        <el-radio label="1" disabled >A<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="2" disabled >B<span class="ml20"></span> 1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="3" disabled >C<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="4" >D<span class="ml20"></span>1次</el-radio>
                                    </li>
                                </el-radio-group>
                            </ul>
                            <div class="question-down clearfix mt20">
                                <span class="fs-14 question-down-left fl fs-14">学员回答∶B</span>
                                <span class="fr">
                                    <img src="../../images/correct-icon.png" alt="">
                                    <span class="fs-14 question-down-right">（得10分）</span>
                                </span>
                            </div>
                        </div>
                        <div class="p-absolute answers-score">（10分）</div>
                    </li>
                    <li class="p-relative mt exam-question ">
                        <div class="question-content mt20">
                            <p class="question-topic">
                                <span>1</span>
                                <span>【单选题】</span>
                                <span>迟到几次不扣工资</span>
                            </p>
                            <ul class="question-options">
                                <el-radio-group v-model="questionRadio">
                                    <li class="mt20 fs-14">
                                        <el-radio label="1" disabled >A<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="2" disabled >B<span class="ml20"></span> 1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="3" disabled >C<span class="ml20"></span>1次</el-radio>
                                    </li>
                                    <li class="mt20 fs-14">
                                        <el-radio label="4" >D<span class="ml20"></span>1次</el-radio>
                                    </li>
                                </el-radio-group>
                            </ul>
                            <div class="question-down clearfix mt20">
                                <span class="fs-14 question-down-left fl fs-14">学员回答∶B</span>
                                <span class="fr">
                                    <img src="../../images/correct-icon.png" alt="">
                                    <span class="fs-14 question-down-right">（得10分）</span>
                                </span>
                            </div>
                        </div>
                        <div class="p-absolute answers-score">（10分）</div>
                    </li>
                </ul>
            </section>


            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="showPaperDetail = false">知道了</el-button>
            </span>
        </el-dialog>

        <!--弹窗-从题库选题-->
        <el-dialog
                title="试卷选择"
                :visible.sync="testBankFlag"
                width="50%"
                center>
            <section class="signup-total">
                <el-input
                        placeholder="请输入内容"
                        prefix-icon="el-icon-search"
                        v-model="input1"
                        class="sign-input">
                </el-input>
            </section>
            <section class="table-box mt">
                <el-table :data="questionBankTopicList" height="300">
                    <el-table-column property="paperName" label="题目" style="text-align: center;"></el-table-column>
                    <el-table-column property="QuestionNum" label="类型"></el-table-column>
                    <el-table-column property="CreateTime" label="知识体系"></el-table-column>
                    <el-table-column property="score" label="题分"></el-table-column>
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-button type="text" size="small">应用</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </section>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="testBankFlag = false">确定</el-button>
            </span>
        </el-dialog>

        <!--弹窗-从试卷库里选择试卷-->
        <el-dialog
                title="试卷选择"
                :visible.sync="testPaperFlag"
                width="50%"
                center>
            <section class="signup-total">
                <el-input
                        placeholder="请输入内容"
                        prefix-icon="el-icon-search"
                        v-model="input1"
                        class="sign-input">
                </el-input>
            </section>
            <section class="table-box mt">
                <el-table :data="testPaperList" height="300">
                    <el-table-column property="paperName" label="试卷名称" style="text-align: center;"></el-table-column>
                    <el-table-column property="QuestionNum" label="试卷题目数"></el-table-column>
                    <el-table-column property="CreateTime" label="创建时间"></el-table-column>
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-button type="text" size="small">应用</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </section>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="testPaperFlag = false">知道了</el-button>
            </span>
        </el-dialog>

        <!-- 删除一道题目 -->
        <el-dialog title="提示" :visible.sync="delOneFlag" width="30%" :before-close="handleClose">
            <span>这是一段信息</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
              </span>
        </el-dialog>

    </section>
</template>

<script>

	import qs from 'qs'
	import com from 'js/common'
	//import editor from '../../components/wangeditor.vue'
	let answerArr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'G', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

	export default{
		data: function(){
			return {
				outTimeId: '',
				answerArr: answerArr,
				tabList:['编辑试卷','发放试卷','考试结果'],
				tabIndex: 0,

				step: 1,      // 编辑试卷步骤， 0, 没有试卷状态 1，编辑试卷  2， 方法试卷   3， 考试结果
				initHasTest: false,      // 是否有试卷

				testBankFlag: false,      // 题库选题弹框
				testPaperFlag: false,      // 卷库中选择弹框

				addBtnFlag: true,      // 是否显示添加试题按钮
				editFlag: false,      // 是否编辑当中
				editTip: '题目请编辑完整，才可以开始其他操作哦！',


				form: {
					Questions: []      // oneEditFlag， 手动添加， 编辑状态
				},
				InfoCateList: [],      // 知识体系


				rules: {
					title: [
						{ required: true, message: '请输入考试名称', trigger: 'blur' }
					],
					desc: [
						{ required: true, message: '请输入考试描述', trigger: 'blur' },
					],
					passScore: [
						{ required: true, message: '请输入合格分数', trigger: 'blur' },
					],
					allowCostTime: [
						{ required: true, message: '请输入考试时长', trigger: 'blur' },
					],
					infoCateID: [
						{ required: true, message: '请选择知识体系', trigger: 'blur' },
					]
				},
			}
		},
		mixins: [mixinMethods],
		methods: {
			tabActive: function(i){
				if(!this.initHasTest){
					this.$message.error(this.editTip);
					this.addBtnFlag = true;
					return ;
				}

				this.tabIndex = i;
				this.step = i;
			},
			outAddBtn: function(){
				clearTimeout(this.outTimeId);
				this.outTimeId = setTimeout(()=>{
					this.addBtnFlag = true;
				}, 600);
			},
			moveAddBtn: function(){
				clearTimeout(this.outTimeId);
			},
			addOver: function(){
				this.addBtnFlag = false
			},
			addOne: function(n, type){      // 添加试题  type(boolean)，true,底部添加按钮

				if(this.editFlag){
					this.$message.error(this.editTip)
					return ;
				}

				this.editFlag = true;
				if(type){
					this.addBtnFlag = true;
				}

				var obj;
// RightAnswerIndex
				if(n==1 || n==2){  // 单选 + 多选
					obj = {QuestionTitle: '', RightScore: '', RightScore: '', CateName: '', RightAnswerIndex: '',
						Answers: [
							{},
							{}
						]
					}
				}else{  // 问答  没有答案-没有分数
					obj = {AnswerValue: '',
						Answers: [
							{},
							{}
						]
					}
				}

				if(n == 1){ // 单选
					obj.QuestionType = 1;
					obj.RightAnswerIndex = [];
				}else if(n == 2){ // 多选
					obj.QuestionType = 2;
					obj.RightAnswerIndex = '';
				}else if(n == 3){ // 问答
					obj.QuestionType = 3;
				}

				obj.editFlag = true;      // 默认编辑状态

				this.form.Questions.push(obj);
			},
			editOne: function(index){
				if(this.editFlag){
					this.$message(this.editTip);
					return ;
				}
				this.form.Questions[index].editFlag = true;
			},
			delOne: function(index){
				if(this.editFlag){
					this.$message(this.editTip);
					return ;
				}

				this.$confirm('确认删除？').then(()=>{
					this.form.Questions.splice(index, 1);
				}).catch( ()=>{
					//
				})

			},

			addAnswerOne: function(index){      // 增加小题中的选项
				var one = this.form.Questions[index];
				if(one){
					one.Answers.push({});
				}

			},
			delAnswerOne: function(outerIndex, index){      // 删除小题中的选项
				var one = this.form.Questions[outerIndex];
				if(one){
					one.Answers = Array.prototype.slice.call(one.Answers, 0);
					one.Answers.splice(index, 1);
				}
			},
			saveAnswerOne: function(outerIndex, type){   // 保存一试题     type 1,多选 2,单选 3 问答
				var status = this.judgeOkOne(outerIndex, type),
					flag = status.flag;

				if(flag){
					console.log(111);
					this.form.Questions[outerIndex].editFlag = false;
					this.editFlag = false;
				}else{
					console.log(222);
					this.$message.error(status.msg);
				}
			},
			judgeOkOne: function(outerIndex, type){     // 判断一试题是否编辑完全

				//return true;

				var one = this.form.Questions[outerIndex],
					answers = one.Answers,
					len = answers.length,
					status = {flag: true, msg: ''};

				if(type == 3){   // 问答
					if(!one.QuestionTitle) return {flag: false, msg: '请输入标题'};
				}else{  // 单选 + 多选
					if(!one.QuestionTitle) return {flag: false, msg: '请输入标题'};
					if(!one.RightScore) return {flag: false, msg: '请输入分数'};
					if(type==1){
						if(one.RightAnswerIndex.length==0) return {flag: false, msg: '请选择正确答案'};
					}else if(type==2){
						console.log('code - valid');
						console.log(one.RightAnswerIndex==='');
						console.log(one.RightAn);
						if(one.RightAnswerIndex==='') {
							console.log(777);
							return {flag: false, msg: '请选择正确答案'};
						}else{
							console.log(888);
						}
					}
					for(var i= 0; i<len; i++){
						if(!answers[i].AnswerValue){
							return {flag: false, msg: '请输入问题描述'};
						}
					}
				}
				return status;
			},

			/* 多选重置设置 */
			judgeCheckOn: function(index, arr){      // 判断选项多选是否选中
				if(arr.indexOf(index) > -1){
					return true;
				}
				return false;
			},
			checkAnswerOne: function(index, arr, limit){     // 操作选中多选按钮   limit, 限制
				var pos = arr.indexOf(index);



				if(pos>-1){
					arr.splice(pos, 1);
				}else{
					arr.push(index);
				}

			},

			submitForm: function(formName){
				this.$refs[formName].validate((valid) => {
					if (valid) {
						this.doAxios();
					} else {
						return false;
					}
				});
			},
			doAxios: function(){
				axios.post('/com/exam/add', qs.stringify(this.form)).then( (res)=>{
					console.log(res);
				} );
			}
		},
		mounted: function(){
			var self = this;
			/*axios.post('/xxx', qs.stringify({})).then( (res) => {
             var d = res.data;
             if(d.flag == 1){
             }
             } )*/

			axios.post('/com/info-cates/list').then( (res)=>{
				var d = res.data;
				if(d.flag == 1){
					this.InfoCateList = d.data.InfoCateList;
				}
			} );

			this.addOne(2, true);
			//this.addOne(1, true);
			//this.addOne(3, true);

		}
	}


</script>